<!DOCTYPE html>  
<html>  
  <head>  
    <title>Encapsulation</title>  
  </head>
  <body>  
    <script type="text/javascript">
      class Car  
      {  
        constructor() {
          var name; // var = restricted access
        }

        // Getter
        getName() {
          return this.name;
        }

        // Setter
        setName(newName) {
          this.name = newName;
        }
      };
      
      var myCar = new Car();
      myCar.setName("John"); // Set the value of the name variable to "John"
      document.write(myCar.getName());
    </script> 
  </body>  
</html>